

package com.nuvo.beans;

import com.nuvo.entities.ArticuloVenta;
import com.nuvo.services.ArticuloVentaService;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;


@ManagedBean
@SessionScoped
public class ArticuloVentaController {
    @EJB
    private ArticuloVentaService articuloVentaService;
    
    
    
    private ArticuloVenta selected;
    
    
    
    public ArticuloVentaController() {
        
    }

    
    
    
    //----metodos del bean---//
    
    public ArticuloVenta getSeledted() {
        if(selected == null){
            selected = new ArticuloVenta();
        }
        return selected;
    }
    
    
    
    public List<ArticuloVenta> listado(){
        return articuloVentaService.findAll();
    
    }
    
   public String index(){
        return "/articulo_venta/index";
    }
    
   
    
    public String nuevo(){
        selected = new ArticuloVenta();
    return "/articulo_venta/new";
    }
    
     public String agregar() {
        articuloVentaService.create(selected);
        return "/articulo_venta/index";
    } 
     
     public String guardar() {
        articuloVentaService.edit(selected);
        return "/articulo_venta/index";
    }
     
      public String editar(int codigo) {
        selected = articuloVentaService.find(codigo);
        return "/articulo_venta/edit";
    }
      
      public String eliminar(int codigo) {
        selected = articuloVentaService.find(codigo);
        articuloVentaService.remove(selected);
        return "/articulo_venta/index";
    } 
      
    
    
}
